﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.SqlClient;

namespace Agresso.Interface.Layer.Domain
{
    public class MaxPostInvoice
    {
        //Header
        public string DocumentType = "";
        public DateTime DocumentDate = new DateTime(2000, 1, 1);
        public DateTime PostingDate = new DateTime(2000, 1, 1);
        public bool InvoiceIndicator = true;
        public string ObjectType = "";
        public string ReferenceDocumentNumber = "";
        public string CompanyCode = "";
        public string VendorID = "";
        public string PurchaseOrderNumber = "";
        public string Currency = "";
        public decimal GrossAmount = 0;
        public decimal NetAmount = 0;
        public DateTime BaselineDate = new DateTime(2000, 1, 1);
        public string HeaderText = "";
        public decimal DeliveryCosts = 0;
        //ReceiverInformation
        public string ReceiverName1 = "";
        public string ReceiverPOCode = "";
        public string ReceiverCity = "";
        public string ReceiverHousenumber = "";
        //SenderInformation
        public string Name1 = "";
        public string BankAccountNumber = "";
        public string BankNumber = "";
        public string TaxNumber1 = "";
        public string VatRegistrationNumber = "";
        //Bankdata
        //BankdataItem
        public string BankAccountNumber_ = "";
        public string BankNumber_ = "";
        //TaxData
        //TaxItem
        public decimal TaxPercentage = 0;
        public decimal TaxAmount = 0;
        public string FileName = "";
        //LineItems
        //LineItem
        public string PurchaseOrderNumber_ = "";
        public string PurchaseOrderItem = "";
        public decimal ItemAmount = 0;
        public decimal ItemDiscount = 0;
        public decimal Quantity = 0;
        public string ItemVendorNumber = "";
        public string ItemText = "";
        //-------------
        public int i_maxpostinvoice_id = 0;
        public string batch_id = "";
        public string remark = "";

        public IList LineItems = new ArrayList();
        public MaxPostInvoice() { }
        public MaxPostInvoice(SqlDataReader rd)
        {
            //Header
            DocumentType = DataConversion.ConvertToString(rd, "DocumentType");
            DocumentDate = DataConversion.ConvertToDateTime(rd, "DocumentDate");
            PostingDate = DataConversion.ConvertToDateTime(rd, "PostingDate");
            InvoiceIndicator = DataConversion.ConvertToBoolean(rd, "InvoiceIndicator");
            ObjectType = DataConversion.ConvertToString(rd, "ObjectType");
            ReferenceDocumentNumber = DataConversion.ConvertToString(rd, "ReferenceDocumentNumber");
            CompanyCode = DataConversion.ConvertToString(rd, "CompanyCode");
            VendorID = DataConversion.ConvertToString(rd, "VendorID");
            PurchaseOrderNumber = DataConversion.ConvertToString(rd, "PurchaseOrderNumber");
            Currency = DataConversion.ConvertToString(rd, "Currency");
            GrossAmount = DataConversion.ConvertToDecimal(rd, "GrossAmount");
            NetAmount = DataConversion.ConvertToDecimal(rd, "NetAmount");
            BaselineDate = DataConversion.ConvertToDateTime(rd, "BaselineDate");
            HeaderText = DataConversion.ConvertToString(rd, "HeaderText");
            DeliveryCosts = DataConversion.ConvertToDecimal(rd, "DeliveryCosts");
            //ReceiverInformation
            ReceiverName1 = DataConversion.ConvertToString(rd, "ReceiverName1");
            ReceiverPOCode = DataConversion.ConvertToString(rd, "ReceiverPOCode");
            ReceiverCity = DataConversion.ConvertToString(rd, "ReceiverCity");
            ReceiverHousenumber = DataConversion.ConvertToString(rd, "ReceiverHousenumber");
            //SenderInformation
            Name1 = DataConversion.ConvertToString(rd, "Name1");
            BankAccountNumber = DataConversion.ConvertToString(rd, "BankAccountNumber");
            BankNumber = DataConversion.ConvertToString(rd, "BankNumber");
            TaxNumber1 = DataConversion.ConvertToString(rd, "TaxNumber1");
            VatRegistrationNumber = DataConversion.ConvertToString(rd, "VatRegistrationNumber");
            //Bankdata
            //BankdataItem
            BankAccountNumber_ = DataConversion.ConvertToString(rd, "BankAccountNumber_");
            BankNumber_ = DataConversion.ConvertToString(rd, "BankNumber_");
            //TaxData
            //TaxItem
            TaxPercentage = DataConversion.ConvertToDecimal(rd, "TaxPercentage");
            TaxAmount = DataConversion.ConvertToDecimal(rd, "TaxAmount");
            FileName = DataConversion.ConvertToString(rd, "FileName");
            //LineItems
            //LineItem
            PurchaseOrderNumber_ = DataConversion.ConvertToString(rd, "PurchaseOrderNumber_");
            PurchaseOrderItem = DataConversion.ConvertToString(rd, "PurchaseOrderItem");
            ItemAmount = DataConversion.ConvertToDecimal(rd, "ItemAmount");
            ItemDiscount = DataConversion.ConvertToDecimal(rd, "ItemDiscount");
            Quantity = DataConversion.ConvertToDecimal(rd, "Quantity");
            ItemVendorNumber = DataConversion.ConvertToString(rd, "ItemVendorNumber");
            ItemText = DataConversion.ConvertToString(rd, "ItemText");
            //-------------
            i_maxpostinvoice_id = DataConversion.ConvertToInt32(rd, "i_maxpostinvoice_id");
            batch_id = DataConversion.ConvertToString(rd, "batch_id"); ;
            remark = DataConversion.ConvertToString(rd, "remark"); ;
        }
        public void AddItem(MaxPostInvoice item)
        {
            item.DocumentType = DocumentType;
            item.DocumentDate = DocumentDate;
            item.PostingDate = PostingDate;
            item.InvoiceIndicator = InvoiceIndicator;
            item.ObjectType = ObjectType;
            item.ReferenceDocumentNumber = ReferenceDocumentNumber;
            item.CompanyCode = CompanyCode;
            item.VendorID = VendorID;
            item.PurchaseOrderNumber = PurchaseOrderNumber;
            item.Currency = Currency;
            item.GrossAmount = GrossAmount;
            item.NetAmount = NetAmount;
            item.BaselineDate = BaselineDate;
            item.HeaderText = HeaderText;
            item.DeliveryCosts = DeliveryCosts;
            item.ReceiverName1 = ReceiverName1;
            item.ReceiverPOCode = ReceiverPOCode;
            item.ReceiverCity = ReceiverCity;
            item.ReceiverHousenumber = ReceiverHousenumber;
            item.Name1 = Name1;
            item.BankAccountNumber = BankAccountNumber;
            item.BankNumber = BankNumber;
            item.TaxNumber1 = TaxNumber1;
            item.VatRegistrationNumber = VatRegistrationNumber;
            item.BankAccountNumber_ = BankAccountNumber_;
            item.BankNumber_ = BankNumber_;
            item.TaxPercentage = TaxPercentage;
            item.TaxAmount = TaxAmount;
            item.FileName = FileName;
            LineItems.Add(item);
        }
    }
}
